<?php
defined('_JEXEC') or die('Restricted access'); 

jimport( 'joomla.html.html.tabs' );
JHtml::_('jquery.framework');
JHTML::_('behavior.tooltip'); 
JHtml::_('behavior.framework');
 
$listOrder	= @$this->lists['order'];
$listDirn	= @$this->lists['order_Dir'];
$user = &JFactory::getUser();
?>

<script type="text/javascript">
function submitform(pressbutton)
{
	var form = document.adminForm;
   	if (pressbutton)
    {form.task.value=pressbutton;}

	if ((pressbutton=='add')||(pressbutton=='publish') ||(pressbutton=='unpublish')||(pressbutton=='remove'))
	{
	  	form.controller.value="complain";
	}
	try 
	{
		form.onsubmit();
	}
	catch(e){}
	form.submit();
}
</script>
<form action="<?php echo JRoute::_("index.php?option=com_wrd")?>" method="post" name="adminForm" id="adminForm" >
       	<?php if (!empty( $this->sidebar)) : ?>
	<div id="j-sidebar-container" class="span2">
		<?php echo $this->sidebar; ?>
	</div>
	<div id="j-main-container" class="span10">
	<?php else : ?>
		<div id="j-main-container">
	<?php endif;?>
	
			<br clear="all">	
    	<div id="filter-bar" class="btn-toolbar">
		<div class="filter-search btn-group pull-left fltlft">
			<label for="filter_search" class="element-invisible">Search</label>
			<input type="text" name="search" id="search" 
			placeholder="<?php echo JText::_('JSEARCH_FILTER'); ?>" 
			value="<?php echo $this->search ?>"  title="" />
		</div>		
		<div class="filter-search btn-group pull-left fltlft">
			<button type="submit" class="btn"><i class="icon-search"></i></button>
			<button type="button" class="btn" onclick="document.id('search').value=''; this.form.submit();"><i class="icon-remove"></i></button>
		</div>
		<div class="btn-group pull-right hidden-phone fltrt">
			<?php echo $this->lists['outlets']; ?>
		</div>
	</div>
	<br clear="all">
    <div id="editcell">
		<table class="table table-striped adminlist">
		<thead>
			<tr>
				<th width="2%"><?php echo JText::_( 'NUM' ); ?></th>
				<th width="3%">
					<?php echo JHtml::_('grid.checkall'); ?>
				</th>
				<th class="title" width="20%">
                	<?php echo JHTML::_('grid.sort',  'Guest Name', 'c.guest_name', $listDirn, $listOrder ); ?>
               	</th>
               	<th class="title" width="5%">
                	<?php echo JHTML::_('grid.sort',  'Member Id', 'c.vip_number', $listDirn, $listOrder ); ?>
               	</th>
				<th width="10%">
					<?php echo JHTML::_('grid.sort',  'Complain Type', 'c.complain_type', $listDirn, $listOrder ); ?>
				</th>
				<th width="10%">
					<?php echo JHTML::_('grid.sort',  'Meal period', 'c.meal_period', $listDirn, $listOrder ); ?>
				</th>
				
				<th width="25%">
				   	<?php echo JHTML::_('grid.sort',  'Outlet', 'outlet.name', $listDirn, $listOrder ); ?>
				</th>
                <th width="5%">
				   	<?php echo JHTML::_('grid.sort',  'Visit Date', 'c.visit_date',$listDirn, $listOrder ); ?>
				</th>
                
				<th width="10%">
				   	<?php echo JHTML::_('grid.sort',  'Created Date', 'c.created_date', $listDirn, $listOrder ); ?>
				</th>
				<th width="10%">
				   	<?php echo JHTML::_('grid.sort',  'Handle By', 'u.handle_name', $listDirn, $listOrder ); ?>
				</th>
			</tr>
		</thead>
		<tbody>
		<?php
		$k = 0;
		for ($i=0, $n= count( $this->items ); $i < $n; $i++):
			$row = &$this->items[$i];
			$checked 	= JHTML::_('grid.checkedout',   $row, $i);
            $canChange	= $user->authorise('core.edit.state', 'com_wrd.complain.'.$row->id);
			$published 	= JHTML::_('jgrid.published', $row->published, $i,'complain.', $canChange,'cb');
			?>
			<tr class="<?php echo "row$k"; ?>"  >
               	<td><?php echo($i+1); ?></td>
                <td><?php echo $checked; ?></td>
				<td>
					<a href='index.php?option=com_wrd&controller=profile&id=<?php echo $this->user_profile[$row->vip_number]->id ; ?>&layout=form'><img src="<?php echo JURI::base().'components/com_wrd/assets/images/details.png' ?>" alt='Profile of <?php echo $row->guest_name; ?>' title='Profile of <?php echo $row->guest_name; ?>' /></a>
					&nbsp;
					
					<a href="index.php?option=com_wrd&controller=complain&id=<?php echo $row->id ?>&layout=form"><?php echo $row->guest_name; ?></a>
				</td>
				<td><?php echo $row->vip_number; ?></td>
				<td>
					<?php 
						switch($row->complain_type){
							case 1:
								echo 'Food' ;
								break;
							case 2:
								echo 'Beverate' ;
								break;
							case 3:
								echo 'Service' ;
								break;
							case 4:
								echo 'Other' ;
								break;
						}
					?>
				</td>
				<td>
					<?php 
						switch($row->meal_period){
							case 1:
								echo 'Breakfast' ;
								break;
							case 2:
								echo 'Lunch' ;
								break;
							case 3:
								echo 'Dinner' ;
								break;
							
						} 
					?>
				</td>
				
				<td><?php echo $row->outlet_name ; ?></td>
                <td><?php echo $row->visit_date ; ?></td>
                <td><?php echo $row->created_date ; ?></td>
                <td><?php echo $row->handle_name ; ?></td>
               
			</tr>
			<?php
            $k = 1 - $k;
		endfor ;
		?>
		</tbody>
		<tfoot>
			<tr>
				<td colspan="16">
                    <?php
                         echo $this->pagination->getListFooter();
                    ?>
                </td>
			</tr>
		</tfoot>
		</table>
	</div>

	<input type="hidden" name="controller" value="complain" />
	<input type="hidden" name="option" value="com_wrd" />
	<input type="hidden" name="task" value="" />
	<input type="hidden" name="boxchecked" value="0" />
    <input type="hidden" name="filter_order" value="<?php echo $this->lists['order']; ?>" />
    <input type="hidden" name="filter_order_Dir" value="<?php echo $this->lists['order_Dir']; ?>" />
	<?php echo JHTML::_( 'form.token' ); ?>
</form>

